home *** CD-ROM | disk | FTP | other *** search
/ The Utilities Experience / The Utilities Experience - Volume 1.iso / software / misc / o-z / x-windows / mesa-amiwin / src / context.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-11-30  |  21.9 KB  |  765 lines

  1. /* context.h */
  2.  
  3. /*
  4.  * Mesa 3-D graphics library
  5.  * Version:  1.2
  6.  * Copyright (C) 1995  Brian Paul  (brianp@ssec.wisc.edu)
  7.  *
  8.  * This library is free software; you can redistribute it and/or
  9.  * modify it under the terms of the GNU Library General Public
  10.  * License as published by the Free Software Foundation; either
  11.  * version 2 of the License, or (at your option) any later version.
  12.  *
  13.  * This library is distributed in the hope that it will be useful,
  14.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  16.  * Library General Public License for more details.
  17.  *
  18.  * You should have received a copy of the GNU Library General Public
  19.  * License along with this library; if not, write to the Free
  20.  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  21.  */
  22.  
  23.  
  24. /*
  25. $Id: context.h,v 1.37 1995/11/22 13:34:49 brianp Exp $
  26.  
  27. $Log: context.h,v $
  28.  * Revision 1.37  1995/11/22  13:34:49  brianp
  29.  * added MutableColors flag
  30.  *
  31.  * Revision 1.36  1995/11/13  21:28:24  brianp
  32.  * added comment about TextureWidth/Height
  33.  *
  34.  * Revision 1.35  1995/11/02  14:57:14  brianp
  35.  * changed LastEnabled to GLint type
  36.  *
  37.  * Revision 1.34  1995/11/01  21:44:15  brianp
  38.  * added CC.Light.LastEnabled
  39.  *
  40.  * Revision 1.33  1995/10/27  20:28:27  brianp
  41.  * added glPolygonOffsetEXT() support
  42.  *
  43.  * Revision 1.32  1995/10/19  15:45:38  brianp
  44.  * added gamma support
  45.  * new arguments to gl_new_context()
  46.  *
  47.  * Revision 1.31  1995/10/17  21:34:03  brianp
  48.  * added typedefs for points_func, line_func, and polygon_func
  49.  *
  50.  * Revision 1.30  1995/10/14  16:26:13  brianp
  51.  * enable dithering by default
  52.  * added SWmasking code
  53.  *
  54.  * Revision 1.29  1995/09/25  16:31:29  brianp
  55.  * reorganized front and back material indexing
  56.  *
  57.  * Revision 1.28  1995/09/15  18:48:52  brianp
  58.  * introduced CC.NewState convention
  59.  * cleaned up comments, removed dead code
  60.  *
  61.  * Revision 1.27  1995/08/01  22:36:12  brianp
  62.  * fixed an extension-compatibility symbol problem
  63.  *
  64.  * Revision 1.26  1995/08/01  22:23:04  brianp
  65.  * added definitions for extension symbols when using non-Mesa header files
  66.  *
  67.  * Revision 1.25  1995/07/25  16:41:54  brianp
  68.  * made changes for using CC.VertexFunc pointer
  69.  *
  70.  * Revision 1.24  1995/07/17  22:32:31  brianp
  71.  * added ClipSpans flag to handle viewports which extend beyond the window
  72.  *
  73.  * Revision 1.23  1995/06/05  20:26:24  brianp
  74.  * added Unfilled field to gl_polygon struct
  75.  *
  76.  * Revision 1.22  1995/05/31  14:32:37  brianp
  77.  * changed BufferWidth, BufferHeight to GLint
  78.  *
  79.  * Revision 1.21  1995/05/22  20:59:34  brianp
  80.  * Release 1.2
  81.  *
  82.  * Revision 1.20  1995/05/17  13:52:37  brianp
  83.  * implemented glIndexMask(0) and glColorMask(0,0,0,0)
  84.  *
  85.  * Revision 1.19  1995/05/17  13:17:22  brianp
  86.  * changed default CC.Mode value to allow use of real OpenGL headers
  87.  * removed need for CC.MajorMode variable
  88.  *
  89.  * Revision 1.18  1995/05/15  16:06:28  brianp
  90.  * implemented shared/nonshared display lists
  91.  *
  92.  * Revision 1.17  1995/05/12  16:30:14  brianp
  93.  * Texture images stored as bytes, not floats
  94.  *
  95.  * Revision 1.16  1995/04/17  13:51:19  brianp
  96.  * added gl_copy_context() function
  97.  *
  98.  * Revision 1.15  1995/04/11  14:04:05  brianp
  99.  * moved CC.write... functions to dd
  100.  *
  101.  * Revision 1.14  1995/03/30  21:08:04  brianp
  102.  * updated to use pointers to CC.write_* functions
  103.  *
  104.  * Revision 1.13  1995/03/27  20:31:26  brianp
  105.  * new Texture.Enabled scheme
  106.  *
  107.  * Revision 1.12  1995/03/24  16:59:41  brianp
  108.  * added gl_update_pixel_logic
  109.  *
  110.  * Revision 1.11  1995/03/24  15:30:10  brianp
  111.  * cleaned up CC struct and removed vertex buffer arrays
  112.  *
  113.  * Revision 1.10  1995/03/22  21:37:22  brianp
  114.  * removed BufferDepth from CC
  115.  *
  116.  * Revision 1.9  1995/03/10  16:26:43  brianp
  117.  * updated for bleding extensions
  118.  *
  119.  * Revision 1.8  1995/03/09  21:39:51  brianp
  120.  * added ModelViewInvValid flag
  121.  *
  122.  * Revision 1.7  1995/03/08  15:10:02  brianp
  123.  * added support for dd_logicop
  124.  *
  125.  * Revision 1.6  1995/03/07  14:20:28  brianp
  126.  * removed ClearColorInt field
  127.  *
  128.  * Revision 1.5  1995/03/04  19:25:29  brianp
  129.  * 1.1 beta revision
  130.  *
  131.  * Revision 1.4  1995/03/02  19:17:02  brianp
  132.  * new RasterMask logic, fixed some comments
  133.  *
  134.  * Revision 1.3  1995/02/27  22:48:33  brianp
  135.  * modified for PB
  136.  *
  137.  * Revision 1.2  1995/02/27  15:07:32  brianp
  138.  * added Vcolor/Vindex scheme
  139.  *
  140.  * Revision 1.1  1995/02/24  14:18:47  brianp
  141.  * Initial revision
  142.  *
  143.  */
  144.  
  145.  
  146. #ifndef CONTEXT_H
  147. #define CONTEXT_H
  148.  
  149.  
  150. #include "GL/gl.h"
  151. #include "config.h"
  152.  
  153.  
  154. struct gl_light {
  155.     GLfloat Ambient[4];        /* ambient color */
  156.     GLfloat Diffuse[4];        /* diffuse color */
  157.     GLfloat Specular[4];        /* specular color */
  158.     GLfloat Position[4];        /* position in eye coordinates */
  159.     GLfloat NormPosition[3];    /* unit vector from origin to pos */
  160.     GLfloat Direction[4];        /* spotlight dir in eye coordinates */
  161.     GLfloat SpotExponent;
  162.     GLfloat SpotCutoff;        /* in degress */
  163.     GLfloat ConstantAttenuation;
  164.     GLfloat LinearAttenuation;
  165.     GLfloat QuadraticAttenuation;
  166.     GLboolean Enabled;        /* On/off flag */
  167. };
  168.  
  169.  
  170. struct gl_lightmodel {
  171.     GLfloat Ambient[4];        /* ambient color */
  172.     GLboolean LocalViewer;        /* Local (or infinite) view point? */
  173.     GLboolean TwoSide;        /* Two (or one) sided lighting? */
  174. };
  175.  
  176.  
  177. struct gl_material {
  178.     GLfloat Ambient[4];
  179.     GLfloat Diffuse[4];
  180.     GLfloat Specular[4];
  181.     GLfloat Emission[4];
  182.     GLfloat Shininess;
  183.     GLfloat AmbientIndex;    /* for color index lighting */
  184.     GLfloat DiffuseIndex;    /* for color index lighting */
  185.     GLfloat SpecularIndex;    /* for color index lighting */
  186. };
  187.  
  188.  
  189.  
  190. /*
  191.  * Attribute structures:
  192.  *    We define a struct for each attribute group to make pushing and
  193.  *    popping attributes easy.  Also it's a good organization.
  194.  */
  195.  
  196.  
  197. struct gl_accum_attrib {
  198.     GLfloat ClearColor[4];    /* Accumulation buffer clear color */
  199. };
  200.  
  201.  
  202. struct gl_colorbuffer_attrib {
  203.     GLuint ClearIndex;        /* Index to use for glClear */
  204.     GLfloat ClearColor[4];        /* Color to use for glClear */
  205.  
  206.     GLuint IndexMask;        /* Color index write mask */
  207.     GLuint ColorMask;        /* bit 3=red,2=green,1=blue,0=alpha*/
  208.         GLboolean SWmasking;        /* Do color/CI masking in software? */
  209.  
  210.     GLenum DrawBuffer;        /* Which buffer to draw into */
  211.  
  212.     /* alpha testing */
  213.     GLboolean AlphaEnabled;        /* Alpha test enabled flag */
  214.     GLenum AlphaFunc;        /* Alpha test function */
  215.     GLfloat AlphaRef;        /* Alpha reference value */
  216.     GLint AlphaRefInt;        /* AlphaRef scaled to an integer */
  217.  
  218.     /* blending */
  219.     GLboolean BlendEnabled;        /* Blending enabled flag */
  220.     GLenum BlendSrc;        /* Blending source operator */
  221.     GLenum BlendDst;        /* Blending destination operator */
  222.     GLenum BlendEquation;        /* BlendEquation EXTENSION */
  223.     GLfloat BlendColor[4];        /* BlendColor EXTENSION */
  224.  
  225.     /* logic op */
  226.     GLboolean LogicOpEnabled;    /* Logic op enabled flag */
  227.     GLboolean SWLogicOpEnabled;    /* Do logic ops in software? */
  228.     GLenum LogicOp;            /* Logic operator */
  229.  
  230.     GLboolean DitherFlag;        /* Dither enable flag */
  231. };
  232.  
  233.  
  234. struct gl_current_attrib {
  235.     GLfloat Color[4];        /* Current RGBA color */
  236.     GLuint Index;            /* Current color index */
  237.     GLfloat Normal[3];        /* Current normal vector */
  238.     GLfloat TexCoord[4];        /* Current texture coordinate */
  239.     GLfloat RasterPos[4];        /* Current raster position */
  240.     GLfloat RasterDistance;        /* Current raster distance */
  241.     GLfloat RasterColor[4];        /* Current raster color */
  242.     GLuint RasterIndex;        /* Current raster index */
  243.     GLfloat RasterTexCoord[4];    /* Current raster texture coord */
  244.     GLboolean RasterPosValid;    /* Raster position valid flag */
  245.     GLboolean EdgeFlag;        /* Current edge flag */
  246. };
  247.  
  248.  
  249. struct gl_depthbuffer_attrib {
  250.     GLenum Func;        /* Function for depth buffer compare */
  251.     GLfloat Clear;        /* Value to clear depth buffer to */
  252.     GLboolean Test;        /* Depth buffering enabled flag */
  253.     GLboolean Mask;        /* Depth buffer writable? */
  254. };
  255.  
  256.  
  257. struct gl_enable_attrib {
  258.     GLboolean AlphaTest;
  259.     GLboolean AutoNormal;
  260.     GLboolean Blend;
  261.     GLboolean ClipPlane[MAX_CLIP_PLANES];
  262.     GLboolean ColorMaterial;
  263.     GLboolean CullFace;
  264.     GLboolean DepthTest;
  265.     GLboolean Dither;
  266.     GLboolean Fog;
  267.     GLboolean Light[MAX_LIGHTS];
  268.     GLboolean Lighting;
  269.     GLboolean LineSmooth;
  270.     GLboolean LineStipple;
  271.     GLboolean LogicOp;
  272.     GLboolean Map1Color4;
  273.     GLboolean Map1Index;
  274.     GLboolean Map1Normal;
  275.     GLboolean Map1TextureCoord1;
  276.     GLboolean Map1TextureCoord2;
  277.     GLboolean Map1TextureCoord3;
  278.     GLboolean Map1TextureCoord4;
  279.     GLboolean Map1Vertex3;
  280.     GLboolean Map1Vertex4;
  281.     GLboolean Map2Color4;
  282.     GLboolean Map2Index;
  283.     GLboolean Map2Normal;
  284.     GLboolean Map2TextureCoord1;
  285.     GLboolean Map2TextureCoord2;
  286.     GLboolean Map2TextureCoord3;
  287.     GLboolean Map2TextureCoord4;
  288.     GLboolean Map2Vertex3;
  289.     GLboolean Map2Vertex4;
  290.     GLboolean Normalize;
  291.     GLboolean PointSmooth;
  292.     GLboolean PolygonOffset;
  293.     GLboolean PolygonSmooth;
  294.     GLboolean PolygonStipple;
  295.     GLboolean Scissor;
  296.     GLboolean Stencil;
  297.     GLuint Texture;
  298.     GLuint TexGen;
  299. };
  300.  
  301.  
  302. struct gl_eval_attrib {
  303.     /* Enable bits */
  304.     GLboolean Map1Color4;
  305.     GLboolean Map1Index;
  306.     GLboolean Map1Normal;
  307.     GLboolean Map1TextureCoord1;
  308.     GLboolean Map1TextureCoord2;
  309.     GLboolean Map1TextureCoord3;
  310.     GLboolean Map1TextureCoord4;
  311.     GLboolean Map1Vertex3;
  312.     GLboolean Map1Vertex4;
  313.     GLboolean Map2Color4;
  314.     GLboolean Map2Index;
  315.     GLboolean Map2Normal;
  316.     GLboolean Map2TextureCoord1;
  317.     GLboolean Map2TextureCoord2;
  318.     GLboolean Map2TextureCoord3;
  319.     GLboolean Map2TextureCoord4;
  320.     GLboolean Map2Vertex3;
  321.     GLboolean Map2Vertex4;
  322.     GLboolean AutoNormal;
  323.     /* Map Grid endpoints and divisions */
  324.     GLuint MapGrid1un;
  325.     GLfloat MapGrid1u1, MapGrid1u2;
  326.     GLuint MapGrid2un, MapGrid2vn;
  327.     GLfloat MapGrid2u1, MapGrid2u2;
  328.     GLfloat MapGrid2v1, MapGrid2v2;
  329. };
  330.  
  331.  
  332. struct gl_fog_attrib {
  333.     GLboolean Enabled;        /* Fog enabled flag */
  334.     GLfloat Color[4];        /* Fog color */
  335.     GLfloat Density;        /* Density >= 0.0 */
  336.     GLfloat Start;            /* Start distance in eye coords */
  337.     GLfloat End;            /* End distance in eye coords */
  338.     GLfloat Index;            /* Fog index */
  339.     GLenum Mode;            /* Fog mode */
  340. };
  341.  
  342.  
  343. struct gl_hint_attrib {
  344.     /* always one of GL_FASTEST, GL_NICEST, or GL_DONT_CARE */
  345.     GLenum PerspectiveCorrection;
  346.     GLenum PointSmooth;
  347.     GLenum LineSmooth;
  348.     GLenum PolygonSmooth;
  349.     GLenum Fog;
  350. };
  351.  
  352.  
  353. struct gl_light_attrib {
  354.     struct gl_light Light[MAX_LIGHTS];    /* Array of lights */
  355.     struct gl_lightmodel Model;        /* Lighting model */
  356.     struct gl_material Material[2];        /* Material 0=front, 1=back */
  357.     GLboolean Enabled;            /* Lighting enabled flag */
  358.     GLenum ShadeModel;            /* GL_FLAT or GL_SMOOTH */
  359.     GLenum ColorMaterialFace;        /* see glColorMaterial */
  360.     GLenum ColorMaterialMode;        /* see glColorMaterial */
  361.     GLboolean ColorMaterialEnabled;        /* see glColorMaterial */
  362.         GLint LastEnabled;            /* a lighting optimization */
  363. };
  364.  
  365.  
  366. struct gl_line_attrib {
  367.     GLboolean SmoothFlag;        /* GL_LINE_SMOOTH enabled? */
  368.     GLboolean StippleFlag;        /* GL_LINE_STIPPLE enabled? */
  369.     GLushort StipplePattern;    /* Stipple pattern */
  370.     GLint StippleFactor;        /* Stipple repeat factor */
  371.     GLfloat Width;            /* Line width */
  372. };
  373.  
  374.  
  375. struct gl_list_attrib {
  376.     GLuint ListBase;
  377. };
  378.  
  379.  
  380. struct gl_pixel_attrib {
  381.     GLenum ReadBuffer;
  382.     GLfloat RedBias, RedScale;    /* Pixel xfer bias & scale values */
  383.     GLfloat GreenBias, GreenScale;
  384.     GLfloat BlueBias, BlueScale;
  385.     GLfloat AlphaBias, AlphaScale;
  386.     GLfloat DepthBias, DepthScale;
  387.     GLint IndexShift;
  388.     GLint IndexOffset;
  389.     GLboolean MapColorFlag;
  390.     GLboolean MapStencilFlag;
  391.     GLfloat ZoomX;            /* Pixel zoom X factor */
  392.     GLfloat ZoomY;            /* Pixel zoom Y factor */
  393.     /* TODO: Do the following belong here??? */
  394.     GLint MapStoSsize;            /* Size of each pixel map */
  395.     GLint MapItoIsize;
  396.     GLint MapItoRsize;
  397.     GLint MapItoGsize;
  398.     GLint MapItoBsize;
  399.     GLint MapItoAsize;
  400.     GLint MapRtoRsize;
  401.     GLint MapGtoGsize;
  402.     GLint MapBtoBsize;
  403.     GLint MapAtoAsize;
  404.     GLint MapStoS[MAX_PIXEL_MAP_TABLE];    /* Pixel map tables */
  405.     GLint MapItoI[MAX_PIXEL_MAP_TABLE];
  406.     GLfloat MapItoR[MAX_PIXEL_MAP_TABLE];
  407.     GLfloat MapItoG[MAX_PIXEL_MAP_TABLE];
  408.     GLfloat MapItoB[MAX_PIXEL_MAP_TABLE];
  409.     GLfloat MapItoA[MAX_PIXEL_MAP_TABLE];
  410.     GLfloat MapRtoR[MAX_PIXEL_MAP_TABLE];
  411.     GLfloat MapGtoG[MAX_PIXEL_MAP_TABLE];
  412.     GLfloat MapBtoB[MAX_PIXEL_MAP_TABLE];
  413.     GLfloat MapAtoA[MAX_PIXEL_MAP_TABLE];
  414. };
  415.  
  416.  
  417. struct gl_point_attrib {
  418.     GLboolean SmoothFlag;    /* True if GL_POINT_SMOOTH is enabled */
  419.     GLfloat Size;        /* Point size */
  420. };
  421.  
  422.  
  423. struct gl_polygon_attrib {
  424.     GLenum FrontFace;    /* Either GL_CW or GL_CCW */
  425.     GLenum FrontMode;    /* Either GL_POINT, GL_LINE or GL_FILL */
  426.     GLenum BackMode;    /* Either GL_POINT, GL_LINE or GL_FILL */
  427.     GLboolean Unfilled;    /* True if back or front mode is not GL_FILL */
  428.     GLenum CullFaceMode;    /* Culling mode GL_FRONT or GL_BACK */
  429.     GLboolean CullFlag;    /* Culling on/off flag */
  430.     GLboolean SmoothFlag;    /* True if GL_POLYGON_SMOOTH is enabled */
  431.     GLboolean StippleFlag;    /* True if GL_POLYGON_STIPPLE is enabled */
  432.         GLfloat OffsetFactor;   /* Polygon offset factor */
  433.         GLfloat OffsetBias;     /* Polygon offset bias */
  434.         GLboolean OffsetEnabled;/* Polygon offset enable */
  435. };
  436.  
  437.  
  438. struct gl_scissor_attrib {
  439.     GLboolean    Enabled;        /* Scissor test enabled? */
  440.     GLint        X, Y;            /* Lower left corner of box */
  441.     GLsizei        Width, Height;        /* Size of box */
  442.     GLint        Xmin, Xmax, Ymin, Ymax;    /* Bounds in window coords */
  443. };
  444.  
  445.  
  446. struct gl_stencil_attrib {
  447.     GLboolean    Enabled;    /* Enabled flag */
  448.     GLenum        Function;    /* Stencil function */
  449.     GLint        Ref;        /* Reference value */
  450.     GLuint        ValueMask;    /* Value mask */
  451.     GLenum        FailFunc;    /* Fail function */
  452.     GLenum        ZPassFunc;    /* Depth buffer pass function */
  453.     GLenum        ZFailFunc;    /* Depth buffer fail function */
  454.     GLuint        Clear;        /* Clear value */
  455.     GLuint        WriteMask;    /* Write mask */
  456. };
  457.  
  458.  
  459. #define Q_BIT 1
  460. #define R_BIT 2
  461. #define S_BIT 4
  462. #define T_BIT 8
  463.  
  464.  
  465. struct gl_texture_attrib {
  466.     GLuint Enabled;            /* Bitwise-OR of 1 and 2 */
  467.     GLenum EnvMode;            /* GL_MODULATE, GL_DECAL, GL_BLEND */
  468.     GLfloat EnvColor[4];
  469.     GLfloat BorderColor[4];        /* TODO: border color 1-D and 2-D */
  470.     GLuint TexGenEnabled;        /* Bitwise-OR of [QRST]_BIT values */
  471.     GLenum GenModeS;        /* Tex coord generation mode, either */
  472.     GLenum GenModeT;        /*    GL_OBJECT_LINEAR, or */
  473.     GLenum GenModeR;        /*    GL_EYE_LINEAR, or    */
  474.     GLenum GenModeQ;        /*      GL_SPHERE_MAP        */
  475.     GLfloat ObjectPlaneS[4];
  476.     GLfloat ObjectPlaneT[4];
  477.     GLfloat ObjectPlaneR[4];
  478.     GLfloat ObjectPlaneQ[4];
  479.     GLfloat EyePlaneS[4];
  480.     GLfloat EyePlaneT[4];
  481.     GLfloat EyePlaneR[4];
  482.     GLfloat EyePlaneQ[4];
  483.     GLenum WrapS1D;            /* GL_CLAMP or GL_REPEAT */
  484.     GLenum WrapT1D;            /* GL_CLAMP or GL_REPEAT */
  485.     GLenum WrapS2D;            /* GL_CLAMP or GL_REPEAT */
  486.     GLenum WrapT2D;            /* GL_CLAMP or GL_REPEAT */
  487.     GLenum MinFilter1D;        /* 1-D minification filter */
  488.     GLenum MagFilter1D;        /* 1-D magnification filter */
  489.     GLenum MinFilter2D;        /* 2-D minification filter */
  490.     GLenum MagFilter2D;        /* 2-D magnification filter */
  491. };
  492.  
  493.  
  494. struct gl_transform_attrib {
  495.     GLenum MatrixMode;            /* Matrix mode */
  496.     GLboolean Normalize;            /* Normalize all normals? */
  497.     GLfloat ClipEquation[MAX_CLIP_PLANES][4];
  498.     GLboolean ClipEnabled[MAX_CLIP_PLANES];
  499.     GLboolean AnyClip;            /* Any ClipEnabled[] true? */
  500.  
  501. };
  502.  
  503.  
  504. struct gl_viewport_attrib {
  505.     GLint X, Y;        /* position */
  506.     GLsizei Width, Height;    /* size */
  507.     GLfloat Near, Far;    /* Depth buffer range */
  508.     GLfloat Sx, Sy, Sz;    /* NDC to WinCoord scaling */
  509.     GLfloat Tx, Ty, Tz;    /* NDC to WinCoord translation */
  510. };
  511.  
  512.  
  513. /* For the attribute stack: */
  514. struct gl_attrib_node {
  515.     GLbitfield kind;
  516.     void *data;
  517.     struct gl_attrib_node *next;
  518. };
  519.  
  520.  
  521. /* Display list info shared by multiple contexts: */
  522. struct gl_list_group {
  523.     union node *List[MAX_DISPLAYLISTS];    /* The display lists */
  524.     GLboolean Reserved[MAX_DISPLAYLISTS];    /* Allocation flags */
  525.     GLint RefCount;                /* Reference count */
  526. };
  527.  
  528.  
  529.  
  530.  
  531. /*
  532.  * Bitmasks to indicate what auxillary information must be interpolated
  533.  * when clipping (CC.ClipMask).
  534.  */
  535. #define CLIP_FCOLOR_BIT        0x01
  536. #define CLIP_BCOLOR_BIT        0x02
  537. #define CLIP_FINDEX_BIT        0x04
  538. #define CLIP_BINDEX_BIT        0x08
  539. #define CLIP_TEXTURE_BIT    0x10
  540.  
  541.  
  542.  
  543. /*
  544.  * Bitmasks to indicate which rasterization options are enabled (CC.RasterMask)
  545.  */
  546. #define ALPHA_BIT        0x01
  547. #define BLEND_BIT        0x02
  548. #define DEPTH_BIT        0x04
  549. #define FOG_BIT            0x08
  550. #define LOGIC_OP_BIT        0x10
  551. #define SCISSOR_BIT        0x20
  552. #define STENCIL_BIT        0x40
  553. #define MASKING_BIT        0x80
  554. #define GAMMA_BIT               0x100
  555.  
  556. #define RASTER_BITS        0x1ff
  557.  
  558.  
  559. typedef void (*points_func)( GLuint first, GLuint last );
  560. typedef void (*line_func)( GLuint v1, GLuint v2, GLuint pv );
  561. typedef void (*polygon_func)( GLuint n, GLuint vlist[], GLuint pv );
  562.  
  563.  
  564.  
  565. /*
  566.  * The library context: 
  567.  */
  568.  
  569. struct gl_context {
  570.     /* Modelview matrix and stack */
  571.     GLfloat ModelViewMatrix[16];
  572.     GLfloat ModelViewInv[16];    /* Inverse of ModelViewMatrix */
  573.     GLboolean ModelViewInvValid;    /* Is the inverse matrix now valid? */
  574.     GLuint ModelViewStackDepth;
  575.     GLfloat ModelViewStack[MAX_MODELVIEW_STACK_DEPTH][16];
  576.  
  577.     /* Projection matrix and stack */
  578.     GLfloat ProjectionMatrix[16];
  579.     GLuint ProjectionStackDepth;
  580.     GLfloat ProjectionStack[MAX_PROJECTION_STACK_DEPTH][16];
  581.  
  582.     /* Texture matrix and stack */
  583.     GLfloat TextureMatrix[16];
  584.         GLboolean IdentityTexMat;    /* Is TextureMatrix==Identity? */
  585.     GLuint TextureStackDepth;
  586.     GLfloat TextureStack[MAX_TEXTURE_STACK_DEPTH][16];
  587.  
  588.     /* Display List stuff */
  589.     GLuint CallDepth;    /* Current recursion calling depth */
  590.     GLboolean ExecuteFlag;    /* Execute GL commands? */
  591.     GLboolean CompileFlag;    /* Compile GL commands into display list? */
  592.     struct gl_list_group *ListGroup;    /* Shared display list group */
  593.  
  594.     /* Attribute stack */
  595.     GLuint AttribStackDepth;
  596.     struct gl_attrib_node *AttribStack[MAX_ATTRIB_STACK_DEPTH];
  597.  
  598.     /* Attribute groups */
  599.     struct gl_accum_attrib        Accum;
  600.     struct gl_colorbuffer_attrib    Color;
  601.     struct gl_current_attrib    Current;
  602.     struct gl_depthbuffer_attrib    Depth;
  603.     struct gl_eval_attrib        Eval;
  604.     struct gl_fog_attrib        Fog;
  605.     struct gl_hint_attrib        Hint;
  606.     struct gl_light_attrib        Light;
  607.     struct gl_line_attrib        Line;
  608.     struct gl_list_attrib        List;
  609.     struct gl_pixel_attrib        Pixel;
  610.     struct gl_point_attrib        Point;
  611.     struct gl_polygon_attrib    Polygon;
  612.     GLuint PolygonStipple[32];
  613.     struct gl_scissor_attrib    Scissor;
  614.     struct gl_stencil_attrib    Stencil;
  615.     struct gl_texture_attrib    Texture;
  616.     struct gl_transform_attrib    Transform;
  617.     struct gl_viewport_attrib    Viewport;
  618.  
  619.     /* PixelStore parameters */
  620.     GLint PackAlignment;
  621.     GLint PackRowLength;
  622.     GLint PackSkipPixels;
  623.     GLint PackSkipRows;
  624.     GLboolean PackSwapBytes;
  625.     GLboolean PackLSBFirst;
  626.     GLint UnpackAlignment;
  627.     GLint UnpackRowLength;
  628.     GLint UnpackSkipPixels;
  629.     GLint UnpackSkipRows;
  630.     GLboolean UnpackSwapBytes;
  631.     GLboolean UnpackLSBFirst;
  632.  
  633.     /* Feedback */
  634.     GLenum FeedbackType;
  635.     GLuint FeedbackMask;
  636.     GLfloat *FeedbackBuffer;
  637.     GLuint FeedbackBufferSize;
  638.     GLuint FeedbackCount;
  639.  
  640.     /* Selection */
  641.     GLuint *SelectBuffer;
  642.     GLuint SelectBufferSize;    /* size of SelectBuffer */
  643.     GLuint SelectBufferCount;    /* number of values in SelectBuffer */
  644.     GLuint SelectHits;        /* number of records in SelectBuffer */
  645.     GLuint NameStackDepth;
  646.     GLuint NameStack[MAX_NAME_STACK_DEPTH];
  647.     GLboolean HitFlag;
  648.     GLfloat HitMinZ, HitMaxZ;
  649.  
  650.     /* Current 1-D texture map */
  651.     GLuint TextureComponents1D[MAX_TEXTURE_LEVELS];
  652.     GLuint TextureWidth1D[MAX_TEXTURE_LEVELS];  /* includes border */
  653.     GLuint TextureBorder1D[MAX_TEXTURE_LEVELS];
  654.     GLubyte *TextureImage1D[MAX_TEXTURE_LEVELS];
  655.     GLboolean TextureImage1DDeleteFlag[MAX_TEXTURE_LEVELS];
  656.  
  657.     /* Current 2-D texture map */
  658.     GLuint TextureComponents2D[MAX_TEXTURE_LEVELS];
  659.     GLuint TextureWidth2D[MAX_TEXTURE_LEVELS];  /* includes border */
  660.     GLuint TextureHeight2D[MAX_TEXTURE_LEVELS]; /* includes border */
  661.     GLuint TextureBorder2D[MAX_TEXTURE_LEVELS];
  662.     GLubyte *TextureImage2D[MAX_TEXTURE_LEVELS];
  663.     GLboolean TextureImage2DDeleteFlag[MAX_TEXTURE_LEVELS];
  664.  
  665.     /* Miscellaneous */
  666.         GLboolean NewState;     /* If GL_TRUE, must call gl_update_state() */
  667.     GLenum RenderMode;    /* either GL_RENDER, GL_SELECT, GL_FEEDBACK */
  668.     GLenum Mode;        /* glBegin primitive or GL_BITMAP */
  669.  
  670.     GLuint StippleCounter;    /* Line stipple counter */
  671.     GLuint ClipMask;    /* OR of CLIP_* values from above */
  672.     GLuint RasterMask;    /* OR of rasterization flags */
  673.     GLuint LightTwoSide;    /* Compute two-sided lighting? */
  674.     GLboolean ComputePlane;    /* Compute plane eq. for polygons? */
  675.     GLfloat PlaneA, PlaneB;    /* Eq. of plane of current polygon */
  676.     GLfloat PlaneC, PlaneD;
  677.  
  678.     GLboolean ClipSpans;    /* Clip pixel spans to window? */
  679.     GLboolean NeedNormals;    /* Are vertex normal vectors needed? */
  680.         GLboolean FastDrawPixels;/* Use optimized glDrawPixels? */
  681.         GLboolean MutableColors;/* Can rasterization effect colors? */
  682.  
  683.     GLboolean RGBAflag;    /* Is frame buffer in RGBA mode, not CI? */
  684.     GLboolean DBflag;    /* Is frame buffer double buffered? */
  685.     GLint BufferWidth;    /* Width of output buffer in pixels */
  686.     GLint BufferHeight;    /* Height of output buffer in pixels */
  687.  
  688.     GLfloat RedScale;    /* These values are used to scale color */
  689.     GLfloat GreenScale;    /* components from the range [0,1] to */
  690.     GLfloat BlueScale;    /* integer values.  It should be the case */
  691.     GLfloat AlphaScale;    /* that: scale = 2^bits - 1 where bits is */
  692.                 /* the number of bits for the component */
  693.                 /* in the frame buffer. */
  694.  
  695.         /* Gamma Correction */
  696.         GLfloat RedGamma;       /* The gamma values, 1=linear */
  697.         GLfloat GreenGamma;
  698.         GLfloat BlueGamma;
  699.         GLubyte RedRamp[256];   /* Gamma lookup tables */
  700.         GLubyte GreenRamp[256];
  701.         GLubyte BlueRamp[256];
  702.  
  703.     /* Special buffers (BS = BufferWidth * BufferHeight): */
  704.     GLint *DepthBuffer;    /* Zbuffer: array [BS] of ints */
  705.     GLubyte *StencilBuffer;    /* Stencil buffer: array [BS] of ubytes */
  706.     ACC_TYPE *AccumBuffer;    /* Acc. buffer: array [4*BS] of components */
  707.  
  708.     GLenum ErrorValue;
  709.  
  710.     /* Current Primitive functions */
  711.     void (*VertexFunc)( GLfloat x, GLfloat y, GLfloat z, GLfloat w );
  712.         points_func PointsFunc;
  713.         line_func LineFunc;
  714.         polygon_func PolygonFunc;
  715.         polygon_func AuxPolygonFunc;
  716. };
  717.  
  718.  
  719.  
  720.  
  721. extern struct gl_context CC;
  722.  
  723.  
  724.  
  725. /*
  726.  * Context creation, initialization, etc.
  727.  */
  728.  
  729. extern void gl_initialize_context( struct gl_context *c );
  730.  
  731. /*
  732. extern struct gl_context *gl_new_context( struct gl_context *shareList );
  733. */
  734.  
  735. extern struct gl_context *
  736. gl_new_context( GLboolean rgb_flag,
  737.                 GLfloat redscale,
  738.                 GLfloat greenscale,
  739.                 GLfloat bluescale,
  740.                 GLfloat alphascale,
  741.                 GLboolean db_flag,
  742.                 struct gl_context *shareList );
  743.  
  744.  
  745. extern void gl_destroy_context( struct gl_context *c );
  746.  
  747. extern void gl_set_context( struct gl_context *c );
  748.  
  749. extern void gl_copy_context( struct gl_context *src, struct gl_context *dst,
  750.                  GLuint mask );
  751.  
  752.  
  753.  
  754. /*
  755.  * Miscellaneous
  756.  */
  757.  
  758. extern void gl_error( GLenum error, char *s );
  759.  
  760.  
  761. extern void gl_update_state( void );
  762.  
  763.  
  764. #endif
  765.